<template>
	<view>
		<view class="body" v-if="kai" :style="{
			'padding-top':'35rpx'
		}">
			<view :style="{
				'justify-content': 'space-between',
				'padding-left': '20rpx',
				'padding-right': '20rpx',
			}
			">
			</view>
			<view class="body_text">
				距离
				<text>{{info.debut_time|timeFormat}}</text>
				直播开始还有
			</view>
			<view class="body_text2">
				<view class="" style="top:30px; position: relative;">
					<u-count-down font-size="38" color="#FFD500" bg-color="rgb(19,19,19)" show-days :timestamp="yt"
						separator="zh" separator-size="28" separator-color="#606266"></u-count-down>
					<view class="body_text_2">
						<image @click="yuye" style="width:200rpx ;height:55rpx ;" src="@/static/img/7wyjot.png" mode="">
						</image>
					</view>
					<view class="body_text_3">{{info.subscribe}}人已预约</view>
				</view>
			</view>
		</view>
		<view v-if="!kai">
			<view v-if="!video"
				style="background-color: black;height: 180px;display: flex;justify-content: center;align-items: center;">
				<image @click="videow" src="@/static/img/bffg.png" style="width: 100rpx;height: 100rpx;" />
			</view>
			<video1 v-if="video" :autoplay='false' @onplay='onplay' :src="info.playback_url" />
		</view>
		<ljkt v-if="!kai" />
		<view class="body2">
			<view style="margin-top: 10rpx;">
				<u-tabs :list="list" active-color='#131314' :is-scroll="false" :current="current" @change="change">
				</u-tabs>
				<view class="xian"></view>
			</view>
			<view v-if="current==0">
				<view class="body2_2">
					<!-- 如何让你的课堂气氛更加活跃 -->
					<view class="body2_2_1">
						{{info.name}}
					</view>
					<view class="body2_2_2">{{info.debut_time|timeFormat}}</view>
					<view class="body2_2_3">
						<u-read-more :toggle="true" show-height="200" open-text='关闭' close-text='展开' color='#91969A'>
							<rich-text
								style="font-size: 28rpx;font-family: Source Han Sans CN;font-weight: 400;color: #131314;opacity: 1;"
								:nodes="info.synopsis" />
						</u-read-more>
					</view>
				</view>
				<view class="body2_3">
					<view class="body2_31">
						主讲人
					</view>
					<view class="body2_3_1">
						<image style="width: 88rpx;height: 88rpx;border-radius: 100%;
						position: relative;top: 10rpx;margin-right: 15rpx;
						" :src="info.lecturer_image" mode=""></image>
						<view class="body2_3_2">
							<text class="body2_3_t1">{{info.lecturer_name}}</text>
							<text class="body2_3_t2">{{info.lecturer_synopsis}}</text>
						</view>

					</view>
				</view>
				<view style="width: 100%;padding: 20rpx;">
					<mp-html :content="info.content" />
				</view>
			</view>
			<view v-if="current==1" style="position: relative;padding-bottom: 100rpx;">
				<view class="topindex">
					<view class="liao">
						<image class="liaoimg" src="https://s4.ax1x.com/2022/01/18/7wOknA.png" />
						<view class="liao2">
							<text>名字名字</text>
							<view class="textn textn01">
								<view class="textn013">
									<view class="textn0">课程内容</view>
									<view class="textn010">欢迎对课程互动</view>
								</view>
								<image style="width: 120rpx;height: 120rpx;"
									src="https://s4.ax1x.com/2022/01/18/7wzclT.png" />
							</view>
						</view>
					</view>
					<view class="xian2"></view>
				</view>
				<!-- 	<view class="liao">
						<image class="liaoimg" :src="item.avatar" />
						<view class="liao2">
							<text>{{item.nickname}}</text>
							<view class="textn">
								{{item.content}}
							</view>
						</view>
					</view> -->
				<view v-for="(item,index) in liuyan.data">
					<view class="liao liaox">
						<image class="liaoimg" :src="item.avatar" />
						<view class="liao2">
							<view lass="liao20" style="text-align: right;font-size: 28rpx;
					font-family: Source Han Sans CN;
					font-weight: bold;
					color: #131314;
					opacity: 1;">{{item.nickname}}</view>
							<view class="textn">
								{{item.content}}
							</view>
						</view>
					</view>
				</view>

				<view class="foot">
					<view class="foot_1">
						<image src="https://s4.ax1x.com/2022/01/18/7BAYxs.png" style="width: 40rpx;height: 40rpx;">
						</image>
						<view style="margin: 10rpx;width: 80%;">
							<input @confirm="fasong" v-model="value" placeholder="写留言，留下你的感悟" />
						</view>
					</view>
				</view>
			</view>

		</view>
		<u-mask :show="show" @click="show = false">
			<view class="warp">
				<view class="rect" @tap.stop>
					<image style="width: 100%;height: 100%;" src="https://s4.ax1x.com/2022/01/18/7wHmQA.png" mode="" />
				</view>
			</view>
		</u-mask>
	</view>
</template>

<script>
	import video1 from '@/components/xiao-video-component/xiao-video-component.vue'
	import uTable from '@/components/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue'
	export default {
		props: ['info', 'yt', 'change2'],
		components: {
			uTable,
			video1
		},
		data() {
			return {
				liuyan: [],
				video: false,
				wsrc: 'https://img.cdn.aliyun.dcloud.net.cn/guide/uniapp/%E7%AC%AC1%E8%AE%B2%EF%BC%88uni-app%E4%BA%A7%E5%93%81%E4%BB%8B%E7%BB%8D%EF%BC%89-%20DCloud%E5%AE%98%E6%96%B9%E8%A7%86%E9%A2%91%E6%95%99%E7%A8%8B@20200317.mp4',
				kai: true,
				danmuList: [],
				value: '',
				show: false,
				cur_id: '',
				height: '',
				shadowStyle: {
					backgroundImage: "none",
					paddingTop: "0",
					marginTop: "20rpx",
				},
				content: '儒家文化作为中国文化最重要的组成部分，对中国 的企业管理起着基础和渗透的作用。在风云变换的商海 ，面对沉浮，企业家如何带领自己的企业化为为机，不 断超越儒家文化作为中国文化最重要的组成部分，对中 国的企业管理起着基础和渗透的作用。在风云变换的商 海，面对沉浮，企业家如何带领自己的企业化为为机， 不断超越。企业家如何带领自己的企业化为为机，不断 超越儒家文化作为中国文化最重要的组成部分，对中国 的企业管理起着基础和渗透的作用。在风云变换的商海 ，面对沉浮，企业家如何带领自己的企业',
				list: [{
					name: '详情'
				}, {
					name: '互动'
				}],
				current: 0
			}
		},
		computed: {},
		onLoad(e) {
			this.cur_id = e.cur_id ? e.cur_id : ''
			this.height = this.$top
		},
		watch: {
			change2(a) {
				console.log(a)
			},
			info(a) {
				let b = parseInt(new Date().getTime() / 1000)
				if (a.debut_time - b > 0) {
					this.kai = true
				} else {
					this.kai = false
				}
			}
		},
		methods: {
			//判断用户是否购买
			videow() {
				if (this.info.purchase == 0) { //没购买
					let a = ''
					if (this.kai) {
						if (this.info.live_status == 2) {
							a = this.info.original_price
						} else {
							a = this.info.live_status
						}
					} else {
						a = this.info.playback_price
					}
					uni.showModal({
						title: '提示',
						content: '观看直播需要' + a + '元',
						success: (res) => {
							if (res.confirm) {
								console.log('用户');
								uni.navigateTo({
									url: `/pages/play/play?money=${this.info.original_price}`
								});
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
				} else {
					this.video = true
				}

			},
			onplay() {
				console.log()
			},
			fasong() {
				if (!this.value) {
					this.$toast('留言不能为空', 0)
					return
				}
				this.$api('broadcast/live_leave', {
					cur_id: this.info.cur_id,
					content: this.value
				}).then(res => {
					if (res.code == 1) {
						this.$toast(res.msg, 1)
						this.value = ''
						this.getliuyan()
						this.$nextTick(function() {
							setTimeout(() => {
								uni.pageScrollTo({
									scrollTop: 99999,
									duration: 0
								})
							}, 200) // 要加点延迟, 不然有可能不生效
						});
					} else {
						this.$toast(res.msg, 0)
					}
				})
			},
			yuye() {
				this.$api('broadcast/subscribe', {
					cur_id: this.info.cur_id
				}).then(res => {
					if (res.code == 1) {
						this.$toast(res.msg, 1)
					} else {
						this.$toast(res.msg, 0)
					}
				})
			},
			kaibo() {},
			change1(status) {},
			getliuyan(a) {
				this.$api('broadcast/live_list', {
					cur_id: this.info.cur_id,
					page: a ? a : 1
				}).then(res => {
					this.liuyan = res.data
				})
			},
			change(index) {
				this.current = index;
				console.log(index)
				if (index == 1) {
					this.getliuyan()
				}
				this.$emit('onc', index)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.foot {
		display: flex;
		position: fixed;
		bottom: 10rpx;
		width: 100%;
		margin: 0rpx 0rpx 0rpx 0rpx;

		.foot_1 {
			padding: 20rpx;

			.fs {
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 500;
				color: #131314;
				opacity: 1;
			}

			padding-left: 20rpx;
			justify-content: space-between;
			display: flex;
			align-items: center;
			width: 100%;
			height: 68rpx;
			background: #F5F5F5;
			border-radius: 50rpx
		}
	}

	.top01 {
		min-height: 510rpx;
		background-size: 100%;
		display: flex;
		justify-content: space-between;
		background-color: rgb(19, 19, 19);
		padding: 20rpx;
	}

	.flexd {
		display: flex;
		justify-content: center;
		align-items: center;
		width: 190rpx;
		height: 142rpx;
		right: 0;
		top: 560rpx;
		background: #FFFFFF;
		box-shadow: 0px 6px 10px rgba(0, 0, 0, 0.1);
		opacity: 1;
		border-radius: 8px;
		position: fixed;
		z-index: 100000;

		.texty {
			font-size: 28rpx;
			font-family: Source Han Sans CN;
			font-weight: 500;
			color: #131314;
			opacity: 1;
		}
	}

	.xian2 {
		height: 0px;
		border: 1rpx solid #E3E3E3;
		margin-top: 50rpx;
		margin-bottom: 10rpx;
		opacity: 1;
	}

	.textn01 {
		display: flex;
		justify-content: space-around;
	}

	.textn013 {
		.textn0 {
			margin-top: 15rpx;
			font-size: 28rpx;
			font-family: Source Han Sans CN;
			font-weight: bold;
			color: #131314;
			opacity: 1;

		}

		.textn010 {
			font-size: 24rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #131314;
			margin-top: 15rpx;
			opacity: 1;
		}
	}

	.liaox {
		.liao2 {
			left: 50rpx !important;

			.textn {
				float: right;
			}
		}

		.liaoimg {
			right: 10rpx;
		}
	}

	.liao {
		padding: 10rpx;
		position: relative;

		.liao2 {
			text {
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: bold;
				color: #131314;
				opacity: 1;
			}

			display: inline-block;
			position: relative;
			left:100rpx;
			top: 15rpx;
			width: 80%;

			.textn {
				max-width: 444rpx;
				background: #F5F5F5;
				border-radius: 8rpx;
				padding: 20rpx;
			}
		}

		.liaoimg {
			width: 88rpx;
			height: 88rpx;
			border-radius: 100%;
			position: absolute;
			top: 0;
		}
	}

	.warp {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	.rect {
		width: 518rpx;
		height: 332rpx;
	}

	.body2_3 {
		padding: 20rpx;
	}

	.body2_31 {
		font-size: 32rpx;
		font-family: Source Han Sans CN;
		font-weight: bold;
		color: #131314;
		opacity: 1;
	}

	.body2_3_2 {
		display: inline-block;

		.body2_3_t1 {
			font-size: 28rpx;
			font-family: Source Han Sans CN;
			font-weight: bold;
			color: #131314;
			opacity: 1;
		}

		.body2_3_t2 {
			font-size: 24rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #91969A;
			opacity: 1;
		}

		text {
			display: block;
		}
	}

	.body2_2 {
		padding: 20rpx;

		.body2_2_1 {
			font-size: 32rpx;
			font-family: Source Han Sans CN;
			font-weight: bold;
			color: #131314;
			opacity: 1;
		}

		.body2_2_2 {
			font-size: 24rpx;
			font-family: HarmonyOS Sans;
			font-weight: 400;
			color: #131314;
			opacity: 1;
		}
	}

	::v-deep .u-tab-bar {
		background-color: #FFD500 !important;
		// width: 40px !important ;
	}

	.xian {
		height: 1px;
		background: #EFEFEF;
		opacity: 1;
		border-radius: 0px;
	}

	.body {
		min-height: 380rpx;
		background-color: #131314;

		.body_1 {
			display: flex;
			justify-content: space-between;
		}

		.body_text_3 {
			font-size: 22rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #FFFFFF;
			opacity: 0.6;
		}

		.body_text2 {
			display: flex;
			justify-content: center;
			text-align: center;

			.body_text_2 {
				margin-top: 50rpx;
			}

			.body_text_1 {
				.w {
					color: white;
					font-size: 24rpx;
					margin-right: 10rpx;
				}

				text {
					color: #FFD500;
					font-size: 38rpx;
				}

				font-size: 24rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #E3E3E3;
				opacity: 1;
			}
		}

		.body_text {
			position: relative;
			top: 30rpx;
			left: 30rpx;

			text {
				color: #FFD500
			}

			font-size: 24rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #E3E3E3;
			opacity: 1;
		}
	}
</style>
